package com.mop.core.es.dao.plugins;

import java.util.Collections;
import java.util.List;

/**
 * @author lemon
 * @ClassName RespPage
 * @desc 响应page
 * @Date 2018/12/12 17:37
 * @Version 1.0
 **/
public class RespPage<T> {

    private Integer current;

    private Integer size;

    private Integer total;

    private Integer pages;

    private List<T> records = Collections.emptyList();

    public Integer getCurrent() {
        return current;
    }

    public void setCurrent(Integer current) {
        this.current = current;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public long getPages() {
        if (this.size == 0) {
            return 0L;
        }
        this.pages = this.total / this.size;
        if (this.total % this.size != 0) {
            this.pages++;
        }
        return this.pages;
    }

    public void setPages(Integer pages) {
        this.pages = pages;
    }

    public List<T> getRecords() {
        return records;
    }

    public void setRecords(List<T> records) {
        this.records = records;
    }
}
